<!--
 * @description  : 案件详情
 * @descriptionDetail: 案件详情
 * @copyright    : 浙江烟草
 * @author       : mwq
 * @create       : 2022-09-27 09:58:58
-->

<template>
  <view>
    <!-- #ifdef H5-ONLY -->
    <!-- 钉钉上不会显示theme-navbar -->
    <theme-navbar
      :is-white="false"
      :title="navTitle"
      :custom-back="goBack"
      style="z-index: 99999"
    >
    </theme-navbar>
    <!-- #endif -->
    <view>
      <view class="sticky-header">
        <u-button type="primary" v-if="pushStatus!='2'" @tap="handleSubmit()">
          确认接收
        </u-button>
        <u-subsection :list="list" :current="current" active-color="#2979ff" @change="changeCurrt"></u-subsection>
      </view>
    </view>
    <view style="height:auto;">
      <!-- 待处理 -->
      <view class="tabsBottom" v-if="current == '0'" style="margin:10px;">
        <u-row>
          <u-col span="12" style="margin-bottom: 5px;">
            <!-- <u-tag text="案件名称:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" /> -->
            <view class="card-number" style="font-size:18px;">
              {{ caseInfo.caseName }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="案发时间:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.caseDate.substring(0,4)+'年'+caseInfo.caseDate.substring(5,7)+'月'+caseInfo.caseDate.substring(8,10)+'日' }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="当事人:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.partyName }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="案件编号:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.caseNo }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="立案单位:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.regOrgName }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="案件性质:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.caseProperty }}
            </view>
          </u-col>
          <u-col span="6" style="margin-bottom: 5px;">
            <u-tag text="案值:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              <span :style="caseInfo.caseValue>50000?'color:red;padding:5px;':'padding:5px;'">{{ caseInfo.caseValue }}</span>元
            </view>
          </u-col>
          <u-col span="6" style="margin-bottom: 5px;">
            <u-tag text="卷烟数量:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              <span :style="caseInfo.cigaBranchQty>5?'color:red;padding:5px;':'padding:5px;'">{{ caseInfo.cigaBranchQty.toFixed(2) }}</span>万支
            </view>
          </u-col>
          <u-col span="6" style="margin-bottom: 5px;">
            <u-tag text="品规数量:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.brandNum }}
            </view>
          </u-col>
          <u-col span="6" style="margin-bottom: 5px;">
            <u-tag text="案件分类:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.caseClassify||'---' }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="案件来源地(起运地):" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.sendPlace }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="案件去向地(到达地):" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.arrivePlace }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="查获地点:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text">
              {{ caseInfo.casePlace }}
            </view>
          </u-col>
          <u-col span="12" style="margin-bottom: 5px;">
            <u-tag text="案件摘要:" border-color="#ecf5ff" style="font-weight:bold;float:left;margin-right:10px;" />
            <view class="card-text" @tap="handleClickText(caseInfo.caseBrief)">
              {{ caseInfo.caseBrief.substring(0,300)+'......' }}
            </view>
          </u-col>
        </u-row>
      </view>
      <!-- 已完成 -->
      <view class="tabsBottom" v-if="current == '1'">
        <t-table
          :loading="custLoading"
          :headers="headColunms"
          :contents="contents"
          :first-line-fixed="true"
          first-col-bg-color="#ecf5ff"
          ref="table"
          @tapCell="handleClick"
        ></t-table>
      </view>
      <view class="tabsBottom" v-if="current == '2'">
        <t-table
          :loading="cigaLoading"
          :headers="cigaHeaders"
          :first-line-fixed="true"
          :contents="cigaContents"
          first-col-bg-color="#ecf5ff"
          ref="table"
          @tapCell="handleClick"
        ></t-table>
      </view>
    </view>
  </view>
</template>
<script>
import MescrollMoreMixin from "@/components/mescroll-uni/mixins/mescroll-more.js";
import TTable from "@/components/t-table";
import majorService from "@/service/internal/major.service";
const screenWidth = uni.getSystemInfoSync().screenWidth;
export default {
  components: {  TTable,},
  mixins: [MescrollMoreMixin,],
  data() {
    return {
      list: [
        {
          name: '基本信息',
        },
        {
          name: '涉案零售户',
        },
        {
          name: '',
        },
      ],
      headColunms:[],
      headers: [
        {
          label: '许可证号',
          width:0.6 * screenWidth,
          align: 'center',
          key: 'licNo',
        },
        {
          label: '卷烟数量',
          key: 'cigaCnt',
          width:0.5 * screenWidth,
          align: 'center',
        },
        {
          label: '关联户名称',
          width:0.9 * screenWidth,
          align: 'center',
          key: 'companyName',
        },
        {     // 标题列
          label: '所属单位',
          key: 'orgName',
          align: 'center',
          width:0.85 * screenWidth,
        }, {
          label: '关联户类别',
          width:0.5 * screenWidth,
          align: 'center',
          key: 'licStatusName',
        },

      ],
      headers2: [
        {
          label: '来源地区',
          width:0.6 * screenWidth,
          align: 'center',
          key: 'sourceAdmivName',
        },
        {
          label: '卷烟品规',
          key: 'cigaName',
          width:0.7 * screenWidth,
          align: 'center',
        },
        {
          label: '卷烟数量',
          width:0.5 * screenWidth,
          align: 'center',
          key: 'cigaQty',
        },
        {     // 标题列
          label: '批发价',
          key: 'tradePr',
          align: 'center',
          width:0.5 * screenWidth,
        },

      ],
      cigaHeaders:[],
      cigaHeaders1: [{     // 标题列
        label: '卷烟名称',
        width:0.5 * screenWidth,
        align: 'center',
        key: 'cigaName',
      },
      {
        label: '前16位码段',
        key: 'firstBitcode',
        width:0.8 * screenWidth,
      }, {
        label: '后16位码段',
        key: 'secondBitcode',
        width:0.8 * screenWidth,
      }, {
        label: '批发价',
        key: 'tradePr',
        width:0.5 * screenWidth,
        align: 'right',
      },
      {
        label: '数量（条）',
        width:0.5 * screenWidth,
        key: 'cigaQty',
        align: 'right',
      },
      ],
      cigaHeaders2: [{     // 标题列
        label: '卷烟名称',
        width:screenWidth,
        align: 'center',
        key: 'cigaName',
      },
      {
        label: '数量（条）',
        width:0.82 * screenWidth,
        key: 'cigaQty',
        align: 'center',
      },
      ],
      current: 0,// 状态码
      custLoading:false,
      cigaLoading:false,
      cigaContents:[],
      tabIndex:0,
      caseUuid:'',
      caseType:'',
      pushStatus:'',
      caseInfo:{},
      contents:[],
    }
  },
  onLoad(v){
    this.caseUuid = v.caseUuid;
    this.caseType = v.caseType;
    this.pushStatus = v.pushStatus;
    this.list[2].name = v.caseType == '02' ? '流入卷烟' : '流出卷烟';
    this.list[1].name = v.caseType == '02' ? '来源地信息' : '涉案零售户' ;
    this.getTrueInfo();
    // this.getInitDocInfo(preParams);
  },
  methods: {
    changeCurrt(index){
      this.current = index;
      this.tabIndex = index;
      if(index == '1'){
        this.headColunms = [];
        if(this.caseType == '01'){
          this.headColunms = this.headers;
          this.getTrueCodeLicList();
        }else{
          this.headColunms = this.headers2;
          this.getTrueCodeSourceList()
        }
      }else if(index == '2'){
        this.cigaHeaders = [];
        if(this.caseType == '01'){
          this.cigaHeaders = this.cigaHeaders1;
          this.getTrueCodeList();
        }else{
          this.cigaHeaders = this.cigaHeaders2;
          this.getTrueCodeSourceCigaList()
        }
      }
    },
    updateBackState(param){
      param.refresh && this.loadData();
    },
    // 用的工作待办接口筛选数据，不用做分页查询，默认多查一批数据出来
    getTrueInfo() {
      let id = this.caseUuid;
      return new Promise(resolve => {
        majorService.getCaseTrueInfoDetailEntityById(1,10,{id,}).then((res) => {
          if(res.success){
            resolve({"data": res.data,});
            this.caseInfo = res.bean;
          }else{
            this.$u.toast(res.msg);
          }
        }).catch((error) => {
          this.$u.toast(error);
        });
      });

    },
    getTrueCodeLicList() {
      this.custLoading = true;
      let trueCaseUuid = this.caseUuid;
      this.contents = [];
      return new Promise(resolve => {
        majorService.getTrueCodeLicList({trueCaseUuid,}).then((res) => {
          if(res.success){
            this.custLoading = false;
            resolve({"data": res.data,});
            this.contents = res.data;
          }else{
            this.$u.toast(res.msg);
          }
        }).catch((error) => {
          this.$u.toast(error);
        });
      });

    },
    getTrueCodeList() {
      this.cigaLoading = true;
      this.cigaContents = [];
      let trueCaseUuid = this.caseUuid;
      return new Promise(resolve => {
        majorService.getTrueCodeList({trueCaseUuid,}).then((res) => {
          if(res.success){
            resolve({"data": res.data,});
            this.cigaLoading = false;
            this.cigaContents = res.data;
          }else{
            this.$u.toast(res.msg);
          }
        }).catch((error) => {
          this.$u.toast(error);
        });
      });

    },
    getTrueCodeSourceList() {
      this.contents = [];
      let trueCaseUuid = this.caseUuid;
      return new Promise(resolve => {
        majorService.getTrueCodeSourceList({trueCaseUuid,}).then((res) => {
          if(res.success){
            resolve({"data": res.data,});
            this.contents = res.data;

          }else{
            this.$u.toast(res.msg);
          }
        }).catch((error) => {
          this.$u.toast(error);
        });
      });

    },
    getTrueCodeSourceCigaList() {
      let trueCaseUuid = this.caseUuid;
      this.cigaContents = [];
      return new Promise(resolve => {
        majorService.getTrueCodeSourceCigaList({trueCaseUuid,}).then((res) => {
          if(res.success){
            resolve({"data": res.data,});
            this.cigaContents = res.data;
          }else{
            this.$u.toast(res.msg);
          }
        }).catch((error) => {
          this.$u.toast(error);
        });
      });

    },
    handleClick({key, data,}) {
      this.$u.toast("点击了" + data[key]);
    },
    handleClickText(data) {
      this.$modal.alert("案件摘要：" + data);
    },
    handleSubmit(){
      this.$modal.confirm("请确认是否接受？", () => {
        majorService.caseSuddenSend({ trueCaseUuid:this.caseUuid,pushStatus:'2',}).then(res => {
          if(res.success){
            this.$u.toast('提交成功');
            this.goBack();
          }
        })
      }, () => {
        this.$u.toast("点击了取消");
      });

    },
  },
}
</script>
<style lang="scss" scoped>
.sticky-header {
  position: fixed;
  bottom: 0px;
  z-index: 999;
  width: 100%;
  line-height:50px;
  background-color: #ffffff;
  border-bottom-right-radius:24rpx;
  border-bottom-left-radius:24rpx;
}
.tabsBottom {
  margin-bottom: 44px;
}
.content {
	background-color: #FFF;
}
.news-li {
	font-size: 32rpx;
	padding: 32rpx;
	border-bottom: 1rpx solid #eee;
}
.news-row {
	width: 100%;
}
.news-logo {
	width: 80rpx;
	height: 80rpx;
	text-align: center;
	// line-height: 80px;
	font-size: 28rpx;
	color: #eee;
	border-radius: 30rpx;
	background: #027aff;
}
.news-logo-finish {
	width: 80rpx;
	height: 80rpx;
	text-align: center;
	// line-height: 80px;
	font-size: 28rpx;
	color: #eee;
	border-radius: 30rpx;
	background: #0BBE62;
}

.news-title {
	font-size: 24rpx;
	font-weight: 600;
	color: #333333;
}

.news-card{
	display: inline-block;
	padding: 8rpx;
	color: #666680;
	font-size: 24rpx;
	background: #EFF3F9;
	margin-right: 16rpx;
}
.card-number{
    font-size: 12px;
    font-weight: 600;
    color:#2979ff;
}
.card-text{
    font-size: 13px;
    font-weight: 500;
    color:#333;
    margin-top:5px;
}
</style>
